﻿/// <reference path="../jquery-vsdoc.js" />
/// <reference path="../jquery-ui.js" />
$(function () {
    if (serverPath == null) {
        serverPath = "/";
    }
    if (loginPartialUrl == null) {
        loginPartialUrl = "/Account/MiniLogOnPartial/";
    }
    //初始化登录对话框
    $("#dialogLogin").dialog({
        resizable: false,
        autoOpen: false,
        width: 220,
        height: 150,
        close: function () {
            $("#loginBox").load(loginPartialUrl);
        }
    });
    //初始化注册对话框
    $("#dialogRegister").dialog({
        autoOpen: false,
        width: 260,
        height: 300,
        resizable: false
    });
    //登录按钮
    $(".btnLogin").click(function () {
        $("#dialogLogin").dialog("open");
    });
    //登录提交按钮
    $("#btnLogOn").button().click(function () {
        var userName = $("#UserName").val();
        var password = $("#Password").val();
        $.ajax({
            url: serverPath + "Account/AjaxLogin",
            type: "POST",
            data:"username="+userName+"&password="+password,
            success: function (result) {
                if (result == "succeed") {
                    $("#dialogLogin").dialog("close");
                }
            }
        });
    })
    //注销按钮
    $("#btnLogOff").click(function () {
        $.ajax({
            url: serverPath + "Account/AjaxLogOff",
            type: "GET",
            success: function () {
                $("#loginBox").load(loginPartialUrl);
            }
        });

    });
    //注册按钮
    $("#btnRegister").click(function () {
        $("#dialogRegister").dialog("open");
        $("#myFrame").attr("src", serverPath + "Account/Register");
    });
});